|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectj3deditor.bin.util.ByteConverter
public class ByteConverter
Tool for converting numbers to byte arrays and vice versa.
| Constructor Summary | |
|---|---|
ByteConverter()
|
|
| Method Summary | |
|---|---|
static byte[] |
getBytes(float nr)
Encodes the given float into a sequence of bytes. |
static byte[] |
getBytes(int nr)
Encodes the given int into a sequence of bytes. |
static byte[] |
getBytes(java.lang.String s)
Encodes the given String into a sequence of bytes using the "utf-8" charset. |
static boolean |
isFlagSet(int allFlags,
int theFlag)
Tests if the given flag is present. |
static java.util.BitSet |
toBits(byte[] bytes)
Returns the bits of the given array of bytes. |
static byte[] |
toBytes(java.util.BitSet bits)
Returns the given bits as the array of bytes. |
static float |
toFloat(byte[] bytes)
Decodes the specified array of bytes to float. |
static int |
toInt(byte[] bytes)
Decodes the specified array of bytes to int. |
static java.lang.String |
toString(byte[] bytes)
Decodes the specified array of bytes to String using "utf-8" charset. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteConverter()
| Method Detail |
|---|
public static byte[] getBytes(int nr)
nr - integer to be encoded
public static byte[] getBytes(float nr)
nr - float to be encoded
public static byte[] getBytes(java.lang.String s)
s - string to be encoded
public static int toInt(byte[] bytes)
throws java.lang.Exception
bytes - byte array to convert
java.lang.Exception - IllegalArgumentException if the length of the given array is not equal to 4,null
public static float toFloat(byte[] bytes)
throws java.lang.Exception
bytes - byte array to convert
java.lang.Exception - IllegalArgumentException if the length of the given array is not equal to 4,null
public static java.lang.String toString(byte[] bytes)
throws java.lang.Exception
bytes - array of bytes to be decoded
java.lang.Exception - if unable to decode the given arraypublic static java.util.BitSet toBits(byte[] bytes)
bytes - bytes which bits will be returned
public static byte[] toBytes(java.util.BitSet bits)
bits - bits that will be converted to an array of bytes
public static boolean isFlagSet(int allFlags,
int theFlag)
allFlags - flags that are bitwise OR'ed togethertheFlag - wanted flag
true if the given flag is set,
otherwise false
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||